package cn.edu.zucc;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.mongodb.repository.config.EnableReactiveMongoRepositories;
import org.springframework.util.ResourceUtils;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

//@ComponentScan(basePackages = {"com.example.*"})
//@EnableReactiveMongoRepositories
@EnableSwagger2
@SpringBootApplication
//@MapperScan("cn.edu.zucc.dao")
public class L03ThymeleafDemoApplication extends WebMvcConfigurationSupport {

	public static void main(String[] args) {
		SpringApplication.run(L03ThymeleafDemoApplication.class, args);
	}

    //这里配置静态资源文件的路径导包都是默认的直接导入就可以
//    @Override
//    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
//        registry.addResourceHandler("/static/**").addResourceLocations(ResourceUtils.CLASSPATH_URL_PREFIX + "/static/");
//        super.addResourceHandlers(registry);
//    }

//    https://www.cnblogs.com/melodyjerry/p/14474416.html
    /**
     * 解决swagger死循环问题
     * 视具体情况用,若控制台报错 No mapping for GET /aifruit/null/swagger-resources/configuration/security
     * 则使用下面代码
     * 下面这几个地址会一直轮询，改为重定向
     * /null/swagger-resources/configuration/ui
     * /null/swagger-resources/configuration/security
     * /null/swagger-resources
     */
//    @Override
//    public void addViewControllers(ViewControllerRegistry registry) {
//        registry.addRedirectViewController("/null/api-docs",
//                "/api-docs").setKeepQueryParams(true);
//        registry.addRedirectViewController("/null/swagger-resources/configuration/ui",
//                "/swagger-resources/configuration/ui");
//        registry.addRedirectViewController("/null/swagger-resources/configuration/security",
//                "/swagger-resources/configuration/security");
//        registry.addRedirectViewController("/null/swagger-resources", "/swagger-resources");
//    }


//————————————————
//    版权声明：本文为CSDN博主「Gy-1-__」的原创文章，遵循CC 4.0 BY-SA版权协议，转载请附上原文出处链接及本声明。
//    原文链接：https://blog.csdn.net/YiQieFuCong/article/details/85009401
}

//2022-04-13 17:08:29.246  WARN 43028 --- [nio-8081-exec-4] o.s.web.servlet.PageNotFound             : No mapping for GET /null/swagger-resources/configuration/ui
